home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 4
/
The Arsenal Files 4 (Arsenal Computer).ISO
/
casm
/
au116-as.exe
/
UTIL
/
GET_NS.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-13
|
2KB
|
94 lines
#include "..\au.hpp"
/*************************************************************************/
static BOOLEAN inside_partial(AU *au, char *file_name, char *partial)
{
char partial_piece[80];
char *ptr, *cur_pos;
int len;
BOOLEAN more = TRUE;
if (partial[0] == '\0')
return TRUE;
cur_pos = partial;
while (more)
{
ptr = strchr(cur_pos, ' ');
if (ptr == NULL)
{
strcpy(partial_piece, cur_pos);
more = FALSE;
}
else
{
len = ptr - cur_pos;
strncpy(partial_piece, cur_pos, len);
ltrim(partial_piece);
partial_piece[len] = '\0';
cur_pos = ptr+1;
while (*cur_pos == ' ')
cur_pos++;
}
if (partial_piece[0] == '\0')
break;
if (wildcard_compare(au, file_name, partial_piece))
return TRUE;
}
return FALSE;
}
/*************************************************************************/
void get_ns(AU *au, char *partial, ARC_HANDLE *arc_handle, LISTPTR *arc_paths,
LISTPTR *arc_files, LISTPTR *paths, LISTPTR *too_long,
LISTPTR *hidden, LISTPTR *dangerous)
{
ARC_RECORD record;
int ret_code;
LIST *el;
for (;;)
{
ret_code = arc_handle->get_record(au, &record);
if (ret_code == EOF)
break;
else if (ret_code == -2)
break;
else if (ret_code == -3)
break;
if (!inside_partial(au, record.name, partial))
continue;
if (record.path[0] != '\0')
{
for (el = paths->head; el != NULL; el=el->next)
{
if (stricmp(record.path, el->data)==0)
break;
}
if (el == NULL)
paths->add(ltrim(record.path));
for (el = dangerous->head; el != NULL; el=el->next)
{
if (stricmp(record.path, el->data)==0)
break;
}
if (el == NULL)
{
/* Path is not relative */
if (strstr(record.path, "..") != NULL || record.path[0] == '\\')
dangerous->add(ltrim(record.path));
}
}
if (!is_dos_name(record.name))
too_long->add(record.name);
if (record.attrib & (0x02 | 0x04))
hidden->add(record.name);
arc_paths->add(ltrim(record.path));
arc_files->add(record.name);
}
return;
}